package pt.utl.ist.calcNotas;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ProgressBar;

import static java.lang.Thread.sleep;


public class StartupFantastico extends Activity {


    private int mProgressStatus = 0;
    private Handler mHandler = new Handler();
    private ProgressBar bar;
    final Context context = this;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.startup_fantastico_layout);
        bar =(ProgressBar)findViewById(R.id.progressBar);
        bar.setMax(100);
        new Thread(new Runnable() {
            public void run() {
                while (mProgressStatus < 100) {
                    try {
                        sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    mProgressStatus++;

                    // Update the progress bar
                    mHandler.post(new Runnable() {
                        public void run() {
                            bar.setProgress(mProgressStatus);
                        }
                    });
                    if(mProgressStatus==100){
                    Intent nextScreen = new Intent(context, MenuFantastico.class);
                    startActivity(nextScreen);}

                }
            }
        }).start();

    }
}